import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestMiniMax extends TestCase {
    private static final Class thisClass = TestMiniMax.class;

    public static void main(String[] args) {
        if (args.length >= 1 && args[0].equals("text")) {
            junit.textui.TestRunner.run(thisClass);
        } else {
            junit.swingui.TestRunner.run(thisClass);
        }
    }

    public static Test suite() {
        return new TestSuite(thisClass);
    }

    public void testWhiteWinning1() {

	// Case: white takes the last black & is crowned within one move
	Board board = Board.parseWdp(".... .b.. .w.. .... .... .... .... .... w");

	MiniMax p = new MiniMax(false,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(MiniMax.WHITE_WIN, bestValue);
    }

    public void testWhiteWinning2() {

	// Case: white blocks the last black within one move
	Board board = Board.parseWdp(".... .... ...b .... ..ww .... .... .... w");

	MiniMax p = new MiniMax(false,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(MiniMax.WHITE_WIN, bestValue);
    }

    public void testBlackWinning1() {

	// Case: black takes the last white & is crowned within one move
	Board board = Board.parseWdp(".... .... .... .... .... .b.. .w.. .... b");

	MiniMax p = new MiniMax(true,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(MiniMax.BLACK_WIN, bestValue);
    }

    public void testBlackWinning2() {

	// Case: black blocks the last white within one move
	Board board = Board.parseWdp(".... .... ..bb .... ...w .... .... .... b");

	MiniMax p = new MiniMax(true,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(MiniMax.BLACK_WIN, bestValue);
    }

    public void testEvalWhiteCrown() {
	// Case: white is crowned within one move
	Board board = Board.parseWdp(".... .w.. .... .... .b.. .... .... .... w");

	MiniMax p = new MiniMax(false,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(Eval.KINGS, bestValue);
    }

    public void testEvalBlackCrown() {
	// Case: black is crowned within one move
	Board board = Board.parseWdp(".... .... .... .w.. .... .... .b.. .... b");

	MiniMax p = new MiniMax(true,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(-Eval.KINGS, bestValue);
    }

    public void testEvalWhiteCapture() {
	// Case: starting with same number of players (eval==0)
	//       white captures one black within one move

	Board board = Board.parseWdp("...b .... .b.. ..w. .... .... .... .w.. w");

	MiniMax p = new MiniMax(false,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(Eval.MEN, bestValue);
    }

    public void testEvalBlackCapture() {
	// Case: starting with same number of players (eval==0)
	//       black captures one white within one move

	Board board = Board.parseWdp("...b .... .b.. ..w. .... .... .... .w.. b");

	MiniMax p = new MiniMax(true,new EvalMaterialOnly(),1);
	int bestValue = p.search(board, 1);
	
	assertEquals(-Eval.MEN, bestValue);
    }

    public void test2stepCapture() {
    }

   
}
